#include<iostream>
using namespace std;
int main()
{
	int T = 0;
	cin >> T;
	while (T--)
	{
		int n, q;
		cin >> n >> q;
		int a[150][2];
		for (int i = 0;i < n;i++)
			for (int j = 0;j < 2;j++)
				cin >> a[i][j];
		while (q--)
		{
			long long hs, ws, hb, wb;
			cin >> hs >> ws >> hb >> wb;
			long long sum = 0;
			for (int i = 0;i < n;i++)
			{
				long long h = a[i][0];
				long long w = a[i][1];
				if (h > hs && w > ws && h < hb && w < wb)
				{
					sum += h * w;
				}
			}
			cout << sum << endl;
		}
	}
	return 0;
}